package cn.hchaojie.camp.day07;

import org.junit.Test;

// 
public class DemoStringBuilder {
	@Test
	public void test() {
		System.out.println(int2String(1234));
	}
	
	// 整数转字符串
	
	public static String int2String(int number) {
		// 1234
		StringBuilder sb = new StringBuilder();

		while (number > 0) {
			int n = number % 10;

			// sb.insert(0, n);	// 取到当前数字，放到字符串前面
			sb.append(n);
			number /= 10;
		}
		
		
		return sb.toString();	// StringBuilder转String
	}
}
